<?php
require('lib/verify.php');
require('lib/has_char.php');
require('lib/is_approved.php');
require('lib/is_admin.php');

$system_id = $system["system_id"];

$credit_id = $_GET["id"];

$sql = "select *, wm_bosses.*, wm_raids.*, wm_instances.* from wm_credits left join wm_bosses on wm_bosses.boss_id = credit_boss left join wm_raids on wm_credits.credit_raid = wm_raids.raid_id left join wm_instances on wm_instances.instance_id = wm_raids.raid_instance where credit_id = '$credit_id' and credit_system_id = $system_id order by credit_date asc";
$res = $db->query($sql);
$credit = $db->fetch_assoc($res);

$sql = "select * from wm_bosses where wm_bosses.boss_trash=1 and wm_bosses.boss_instance = " . $credit["instance_id"];
$res = $db->query($sql);
$trash = $db->fetch_assoc($res);
$trash_id = $trash["boss_id"];

if($system["system_tier"]==5) {
  $sql = "select * from wm_bosses where wm_bosses.boss_trash=1 and wm_bosses.boss_instance = 8";
  $res = $db->query($sql);
  $trashh = $db->fetch_assoc($res);
  $trashh_id = $trashh["boss_id"];
}

if($system["system_tier"]==6) {
  $sql = "select * from wm_bosses where wm_bosses.boss_trash=1 and wm_bosses.boss_instance = 11";
  $res = $db->query($sql);
  $trashh = $db->fetch_assoc($res);
  $trashh_id = $trashh["boss_id"];
}


$_category = "warmath";
$_title = "Admin / Add Loot: Step 1 of 2";
require('lib/head.php');

boxTop("Warmath: $_title");
?>
<b>Add Loot</b><br />
to 
<a href="credit.php?id=<?=$credit["credit_id"]?>"><?=$credit["boss_name"]?>, <?=date("g:i a", strtotime($credit["credit_date"]))?></a> in <a href="raid.php?id=<?=$credit["raid_id"]?>"><?=$credit["instance_name"]?>, <?=date("D d M Y", strtotime($credit["raid_date"]))?></a><br />

<br />
<form action="add-loot-2.php" method="post">
<input type="hidden" name="loot_credit" value="<?=$credit["credit_id"]?>">
<b>Loot</b><br />
<i>What dropped?  Remember to go in alphabetical order.</i><br />
<select name="loot_item">
<?php
$sql = "select *, item_cache.* from wm_items left join item_cache on wm_items.item_id = item_cache.item_id where item_boss = '" . $credit["boss_id"] . "' order by item_cache.item_name asc";

$result = $db->query($sql);
while($item = $db->fetch_assoc($result)) {
?>
 <option value="<?=$item["item_id"]?>"><?=$item["item_name"]?>
<?php
}

$sql = "select *, item_cache.* from wm_items left join item_cache on wm_items.item_id = item_cache.item_id where item_boss = '" . $trash_id . "' order by item_cache.item_name asc";
$result = $db->query($sql);
while($item = $db->fetch_assoc($result)) {
?>
 <option value="<?=$item["item_id"]?>"><?=$item["item_name"]?>
<?php
}

if($system["system_tier"]>4) {

$sql = "select *, item_cache.* from wm_items left join item_cache on wm_items.item_id = item_cache.item_id where item_boss = '" . $trashh_id . "' order by item_cache.item_name asc";
$result = $db->query($sql);
while($item = $db->fetch_assoc($result)) {
?>
 <option value="<?=$item["item_id"]?>"><?=$item["item_name"]?>
<?php
}

}

//then trash loot
?>

</select>
<br />
<br />
<input type="submit" value="Continue">
</form>

<br /><br />

<a href="credit.php?id=<?=$credit_id?>">Nothing looted.</a>

<br /><br />
<?php
boxBot();
?>

<?php
require('lib/foot.php');
?>

